﻿
namespace ArchitectureExample.Domain.Users
{
    using Patterns4Net.Attributes.Relations;
    using Patterns4Net.Attributes.DesignPatterns;

    /// <summary>
    /// Represents a user of our application.
    /// A user may be <c>registered</c> or <c>unregistered</c>.
    /// </summary>
    /// <remarks>
    ///     <para>
    ///         User's internal behavior is directed by an instance of <see cref="IUserState"/>, 
    ///         which implements the State pattern.
    ///     </para>
    ///     <para>
    /// 
    ///         If you don't know how to instantiate a user, here is a small example:
    /// <code>
    /// var user = new User();
    /// if (user == null) {
    ///     something really strange has happend...
    /// }
    /// </code>
    ///     </para>
    /// </remarks>
    public class User
    {
        [Composition]
        private IUserState state = new UnregisteredUser();

        public void Register()
        {
            this.state = new RegisteredUser();
        }

        public Address Address { get; set; }

        public User Supervisor { get; set; }

        public Email Email { get; set; }

        [State]
        public interface IUserState
        {
        }

        public class UnregisteredUser : IUserState
        {
        }

        public class RegisteredUser : IUserState
        {
        }
    }
}
